package linz.dsl

fun main() {
    person { // 持有this 中转站1 == { student， teacher， worker }
        student { // 持有this 中转站2 == { study， fraction }
            study("数学")
            score(98.3)
        }
        teacher {
            myCourse("语文")
        }
        worker {
            inputWorker("汽修工程师")
            inputSalary(20000.0)
        }
    }
}


fun person(lambda: PersonInput.()-> Unit): PersonInput{
    val person = PersonInput()
    person.lambda()
    return person
}

 class PersonInput{
    init {
        println("人员录入系统")
    }

    fun student(lambda: Student.() -> Unit ):Student {
        val student = Student("学生录入开始")
        student.lambda()
        return student
    }

    fun teacher(lambda:Teacher.()->Unit):Teacher{
        val teacher = Teacher("老师信息录入")
        teacher.lambda()
        return teacher
    }

    fun worker(lambda:Worker.()->Unit):Worker{
        val teacher = Worker("老师信息录入")
        teacher.lambda()
        return teacher
    }
}
class Student(info:String){

    init {
        println("【${info}】")
    }

    fun study(stuInfo:String){
        println("学习内容：$stuInfo")
    }

    fun score(score:Double){
        println("分数：$score")
    }

}

class Teacher(info:String){

    init {
        println("【${info}】")
    }

    fun myCourse(course: String) {
        println("你的授课内容是:$course")
    }
}

class Worker(info:String){

    init {
        println("【${info}】")
    }
    fun inputWorker(workerInfo: String) {
        println("你的工作信息是:$workerInfo")
    }
    fun inputSalary(salary: Double) {
        println("你的工作薪资是:$salary")
    }
}